package com.example.traning.security.controller;

import com.example.traning.security.controller.vo.AuthLoginReqVO;
import com.example.traning.security.controller.vo.AuthLoginRespVO;
import com.example.traning.security.util.SecurityUtils;
import org.springframework.web.bind.annotation.*;

/**
 * @author lei yu
 * @since 2024/10/14
 */
@RequestMapping("/security")
@RestController
public class SecurityController {


    //    @PermitAll
    @PostMapping("/login")
    public AuthLoginRespVO login(@RequestBody AuthLoginReqVO reqVO) {
        // 验证用户
        // ... ...

        String token = SecurityUtils.setToken();
        return new AuthLoginRespVO().setAccessToken(token).setUserId(1L);
    }

    @GetMapping("/echo")
    public String echo() {
        return "echo";
    }

    @GetMapping("/home")
    public String home() {
        return "我是首页";
    }
}
